"""
 -*- coding: utf-8 -*-
 @Time : 2023/11/21 15:18
 @Author : 支晓光
 @Email : 1473858993@qq.com
 @File : appium_driver.py
 @Project : youguuUI
 """

import yaml
from appium import webdriver
from common.handler_path import driver_dir




class AppiumDriver:
    def __init__(self, **kwargs):
        # 读取yaml文件
        f = open(driver_dir, encoding='utf8')
        # 解析yaml文件，Loader=yaml.FullLoader提高代码安全性
        capabilities = yaml.load(f, Loader=yaml.FullLoader)
        #
        for key, value in kwargs.items():
            capabilities[key] = value

        self.driver = webdriver.Remote('http://localhost:4723', capabilities)
        self.driver.implicitly_wait(8)


driver = AppiumDriver().driver
